/*
The MIT License (MIT)

Copyright (c) 2016, Unity Technologies

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

This file is taken from:
https://github.com/Unity-Technologies/NativeRenderingPlugin
*/

#pragma once
#include "IUnityInterface.h"

typedef enum UnityGfxRenderer {
  // kUnityGfxRendererOpenGL            =  0, // Legacy OpenGL, removed
  // kUnityGfxRendererD3D9              =  1, // Direct3D 9, removed
  kUnityGfxRendererD3D11 = 2,         // Direct3D 11
  kUnityGfxRendererGCM = 3,           // PlayStation 3
  kUnityGfxRendererNull = 4,          // "null" device (used in batch mode)
  kUnityGfxRendererOpenGLES20 = 8,    // OpenGL ES 2.0
  kUnityGfxRendererOpenGLES30 = 11,   // OpenGL ES 3.0
  kUnityGfxRendererGXM = 12,          // PlayStation Vita
  kUnityGfxRendererPS4 = 13,          // PlayStation 4
  kUnityGfxRendererXboxOne = 14,      // Xbox One
  kUnityGfxRendererMetal = 16,        // iOS Metal
  kUnityGfxRendererOpenGLCore = 17,   // OpenGL core
  kUnityGfxRendererD3D12 = 18,        // Direct3D 12
  kUnityGfxRendererVulkan = 21,       // Vulkan
  kUnityGfxRendererNvn = 22,          // Nintendo Switch NVN API
  kUnityGfxRendererXboxOneD3D12 = 23  // MS XboxOne Direct3D 12
} UnityGfxRenderer;

typedef enum UnityGfxDeviceEventType {
  kUnityGfxDeviceEventInitialize = 0,
  kUnityGfxDeviceEventShutdown = 1,
  kUnityGfxDeviceEventBeforeReset = 2,
  kUnityGfxDeviceEventAfterReset = 3,
} UnityGfxDeviceEventType;

typedef void(UNITY_INTERFACE_API* IUnityGraphicsDeviceEventCallback)(
    UnityGfxDeviceEventType eventType);

// Should only be used on the rendering thread unless noted otherwise.
UNITY_DECLARE_INTERFACE(IUnityGraphics) {
  UnityGfxRenderer(UNITY_INTERFACE_API * GetRenderer)();  // Thread safe

  // This callback will be called when graphics device is created, destroyed,
  // reset, etc. It is possible to miss the kUnityGfxDeviceEventInitialize event
  // in case plugin is loaded at a later time, when the graphics device is
  // already created.
  void(UNITY_INTERFACE_API *
       RegisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback);
  void(UNITY_INTERFACE_API * UnregisterDeviceEventCallback)(
      IUnityGraphicsDeviceEventCallback callback);
  int(UNITY_INTERFACE_API * ReserveEventIDRange)(
      int count);  // reserves 'count' event IDs. Plugins should use the result
                   // as a base index when issuing events back and forth to
                   // avoid event id clashes.
};
UNITY_REGISTER_INTERFACE_GUID(0x7CBA0A9CA4DDB544ULL,
                              0x8C5AD4926EB17B11ULL,
                              IUnityGraphics)

// Certain Unity APIs (GL.IssuePluginEvent, CommandBuffer.IssuePluginEvent) can
// callback into native plugins. Provide them with an address to a function of
// this signature.
typedef void(UNITY_INTERFACE_API* UnityRenderingEvent)(int eventId);
typedef void(UNITY_INTERFACE_API* UnityRenderingEventAndData)(int eventId,
                                                              void* data);
